package com.zaoshui.hudada.mapper;

import com.zaoshui.hudada.model.dto.statistics.AppAnswerStatisticsDTO;
import com.zaoshui.hudada.model.dto.statistics.HotAppStaticsDTO;
import org.apache.ibatis.annotations.Select;
import org.mapstruct.Mapper;

import java.util.List;

@Mapper
public interface StatisticsMapper {

    //根据appId进行分组获取每个应用用户回答的数量
    @Select("select appId,count(appId) as answerCount from user_answer group by  appId order by answerCount desc limit 10")
    List<HotAppStaticsDTO> getHotAppStatics();

    //以appId作为条件，对resultName进行分组，获取每个应用用户回答结果的比例
    @Select("select resultName, count(userId) as answerCount from user_answer where appId = 1794181252131885058 group by resultName")
    List<AppAnswerStatisticsDTO> getAppAnswerStatistics(long appId);
}
